package me.spring.cloud.components.starter.version.core;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author luffy
 * @date 2019-04-18 14:18
 */
@Getter
@AllArgsConstructor
public enum VersionOperator {
  NIL(""),
  LT("<"),
  GT(">"),
  LTE("<="),
  GTE(">="),
  NE("!="),
  EQ("==");
  private String code;

  public static VersionOperator parse(String code) {
    for (VersionOperator operator : VersionOperator.values()) {
      if (operator.getCode().equalsIgnoreCase(code)) {
        return operator;
      }
    }
    return null;
  }

}
